<template>
	<div class="addhotpic">
		<div style="width: 56%;">
			<div>
				<el-upload :multipe="false" :auto-upload="false" :file-list="fileList" :on-change="handleChange"
					list-type="picture"  action = "uploadAction" accept="image/jpg,image/jpeg">
					<h3>点击添加图片</h3>
				</el-upload>
			</div>
			<el-form ref="form" :model="form" label-width="80px" size="mini">
				<el-form-item label="类型整数" prop="type">
					<el-input v-model="form.type"></el-input>
				</el-form-item>
				<el-form-item label="优先级-整数" prop="hot">
					<el-input v-model="form.hot"></el-input>
				</el-form-item>
				<el-form-item label="描述" prop="memo">
					<el-input type="textarea" :rows="5" placeholder="请输入书籍详情" v-model="form.memo">
					</el-input>
				</el-form-item>
			</el-form>
			<el-button type="primary" @click="add('arr')">立即添加</el-button>
		</div>
	</div>
</template>

<script>
	export default {
		name: 'AddMovList',
		data() {
			return {
				form: {
					id: 0,
					picture: ''
				},
				fileList: [],
			}
		},
		methods: {
			handleChange(file, fileList) {
				this.fileList = fileList; //获取文件内容
			},
			add() {
				let formData = new FormData();
				if (this.fileList.length > 0 && this.fileList[0].raw != null) {
					formData.append("mypic", this.fileList[0].raw);
				}
				formData.append("id", this.form.id);
				formData.append("memo", this.form.memo);
				formData.append("hot", this.form.hot);
				formData.append("picture", this.form.picture);
				formData.append("type", this.form.type);
				var that = this;
				this.$postf("/api/adm/hot/add", formData).then(resp => {
					this.$message.error(resp.data.msg);
					console.log(resp.data.data);
					if (resp.data.code == 200) {
						this.form = resp.data.data;
						console.log(this.form);
					}
				})
			},
		},
		
	}
</script>

<style>
	.addhotpic{
		width: 85%;
	}
</style>